package com.learning.db.optimization;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class SortDate extends WritableComparator {

    public SortDate() {
        super(DBYB_dataBean.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        DBYB_dataBean o1 = (DBYB_dataBean) a;
        DBYB_dataBean o2 = (DBYB_dataBean) b;

        int compare = o1.getPersonId().compareTo(o2.getPersonId());
        return compare == 0 ? (o1.getSettlementDate().compareTo(o2.getSettlementDate()) == 0 ? o1.getMedicalId().compareTo(o2.getMedicalId()) : o1.getSettlementDate().compareTo(o2.getSettlementDate())) : compare;
//        return compare == 0 ? Long.compare(o1.getSettlementDate(), o2.getSettlementDate()) : compare;
    }
}